Pot = cc.Node.extend({
	ctor:function(p){
		this._super();
		p.addChild(this, 11, TAG_POT_NODE);
		this.init();
	},
	init:function(){
		var pot = new Button(this, 6, TAG_POT, "#pot.png",this.callback);
		this.setCascadeOpacityEnabled(true);
	},
	smoking:function(){
		var smoke = new cc.Sprite("#smoke/1.png");
		smoke.setScale(0.5);
		smoke.setPosition(0, 80);
		this.addChild(smoke, 10);
		
		var animFrames = [];
		for (var i = 1; i < 10; i++) {
			var str = "smoke/" + i + ".png";
			var frame = cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation = new cc.Animation(animFrames, 0.15);
		var action = cc.animate(animation);
		var repeat = cc.repeat(action, 5);
		var seq = cc.sequence(repeat, cc.fadeOut(0.3));
		smoke.runAction(seq);
	},
	showNaCl:function(){
		var pot = this.getChildByTag(TAG_POT);
		var pot2 = new cc.Sprite("#pot2.png");
		pot2.setOpacity(0);
		pot2.setPosition(0, pot.height + pot2.height * 0.5);
		this.addChild(pot2);
		var seq = cc.sequence(cc.fadeIn(0.5),cc.delayTime(2),cc.fadeOut(0.5));
		pot2.runAction(seq);
	},
	callback:function(p){
		var func = cc.callFunc(this.actionDone, this);
		switch(p.getTag()){
		case TAG_POT:
			var move = cc.moveTo(0.5,cc.p(320, 380));
			var rotate = cc.rotateTo(0.3,30);
			var fade = cc.fadeTo(0.5, 0);
			var delay = cc.delayTime(2.5);
			var seq = cc.sequence(move, rotate, func, delay, fade, cc.callFunc(function(){
				gg.flow.next();
			}, this));
			this.runAction(seq);
			break;
		}	
	},
	actionDone:function(p){
		switch(p.getTag()){
			case TAG_POT_NODE:
				var spoon = this.getParent().getChildByTag(TAG_SPOON);
				var move = cc.moveTo(0.5,cc.p(340,430));
				var rotate = cc.rotateTo(0.3, 90);
				var spawn = cc.spawn(move, rotate);
				var moveSeq = cc.sequence(cc.moveBy(0.3,cc.p(40, -20)),cc.moveBy(0.3,cc.p(-40, 20)));
				var repeat = cc.repeat(moveSeq, 3);
				var func = cc.callFunc(function(){
					var bushi = this.getParent().getChildByTag(TAG_AIR).getChildByTag(TAG_AIR_FUNNEL);
					var salt = new cc.Sprite("#salt5.png");
					salt.setScale(0.3);
					salt.setOpacity(0);
					salt.setPosition(15, 75);
					bushi.addChild(salt, 1, TAG_BUSHI_SALT);
					salt.runAction(cc.fadeIn(0.5));
				}, this);
				var move2 = cc.moveTo(0.5,cc.p(700,400));
				var seq = cc.sequence(spawn, moveSeq, repeat, func, move2);
				spoon.runAction(seq);
				break;
		}
	}
	
});